import { get, post, put, del } from '@utils/request'
import type { BaseResponse, PaginationParams, PaginationResponse } from '@types'

export interface ShareInfo {
  id: string
  title: string
  content: string
  author: string
  createdAt: string
  updatedAt: string
  status: 'draft' | 'published' | 'archived'
}

export interface CreateShareRequest {
  title: string
  content: string
}

export interface UpdateShareRequest extends Partial<CreateShareRequest> {
  id: string
}

// 获取分享列表
export const getShareList = (params: PaginationParams) => 
  get<PaginationResponse<ShareInfo>>('/api/shares', params)

// 获取分享详情
export const getShareDetail = (id: string) => 
  get<ShareInfo>(`/api/shares/${id}`)

// 创建分享
export const createShare = (data: CreateShareRequest) => 
  post<ShareInfo>('/api/shares', data)

// 更新分享
export const updateShare = (data: UpdateShareRequest) => 
  put<ShareInfo>(`/api/shares/${data.id}`, data)

// 删除分享
export const deleteShare = (id: string) => 
  del<BaseResponse>(`/api/shares/${id}`)